package hyrpt

import java.text.SimpleDateFormat


class InspectionRecordController {
    def dynamicQueryService
    def inspectionRecord() {
        SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd')
        def startTime = params.startTime ? sdf.parse(params.startTime) : sdf.parse(sdf.format(new Date().clearTime()))
        def endTime = params.endTime ? sdf.parse(params.endTime) : sdf.parse(sdf.format(new Date()))
        params.startTime = sdf.format(startTime)
        params.endTime = sdf.format(endTime)
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def tableHeadList = []
        def inspectionRecord = []
        def pageSizeList = [10, 20, 50, 100]
        def totalCount = 0
        if (params.EXPORT_CONTENT_NAME == 'Excel') {
            params.SYS_QUERY_NAME = 'inspectionRecord'
            inspectionRecord = dynamicQueryService.queryForList(params)
            if(inspectionRecord.size()>0) {
                tableHeadList = inspectionRecord[0].keySet()
            }
            params.SYS_QUERY_NAME = 'inspectionRecordCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
        }

        [startno      : params.startno ?: '',
         endno        : params.endno ?: '',
         pageSize     : pageSize,
         totalCount   : totalCount,
         pageSizeList : pageSizeList,
         tableHeadList: tableHeadList,
         inspectionRecord   : inspectionRecord,
         startTime    : params.startTime ?: '',
         endTime      : params.endTime ?: '',
         partName     : params.partName ?: '',
         stepDesc        : params.stepDesc ?: '',
         lotId        : params.lotId ?: '',
         endDocId     : params.endDocId ?: '',
         eqp          : params.eqp ?: '',
         unYieldCont:params.unYieldCont?:'',
                chuZhi:params.chuZhi?:''
        ]
    }
}
